@overview-border-light-gray: #ededed;
@overview-border-gray: #d6d6d6;
@shield-bgcolor:       #ebebeb;
@shield-border-color:  @overview-border-gray;
@shield-width:         36px;
@shield-width-lg:      50px;
@service-group-vertical-margin: 6px;
@service-group-horizontal-margin: 8px;
@two-column-min-width: 568px;

.overview {
  font-weight: 300;
  h2 {
    line-height: 1.4;
  }
  .container-fluid {
    margin-top: 20px;
    @media (min-width: @screen-md-min) {
      margin-top: 30px;
    }
  }
  /* Can remove some of these styles when we dump the old overview and its old build-block styles */
  .builds-block {
    background-color: #fff;
    margin-left: 0;
    border-right: 1px solid @overview-border-gray;

    .builds {
      overflow: inherit;

      .build {
        padding-bottom: 0;
        padding-top: 0;
        padding-left: 14px;
        border-radius: 0;

        &:first-child {
          padding-top: 5px;
        }

        &:last-child {
          border-bottom: 1px solid @overview-border-gray;
          padding-bottom: 5px;
        }
      }
    }
  }
  .loading-message {
    font-weight: normal;
    margin-top: 5px;
  }
  .service-group-with-route-row .service-group,
  .standalone-service-row .service-group {
    margin-bottom: 25px;
    position: relative;
    width: 100%;
    &:before {
      content: "";
      display: block;
      height: 100%;
      width: 3px;
      position: absolute;
      background: @color-pf-light-blue-400;
      left: 0;
      z-index: 1;
    }
    .alert-wrapper {
      width: 100%;
      // offset to left margin so alert right edge aligns
      padding-right: @service-group-horizontal-margin;
      .alert {
        width: 100%;
        border-color: @overview-border-gray;
        margin-bottom: 0;
        margin-left: @service-group-horizontal-margin;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
        .pficon {
          box-shadow: none;
          //box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
        }
        .close {
          color: #8b8d8f;
        }
      }
    }
  }
  .service-group-with-route-row .service-group .alert-wrapper .alert {
    margin-top: @service-group-vertical-margin;
  }
  .standalone-service-row .service-group .alert-wrapper .alert {
    margin-bottom: @service-group-vertical-margin;
  }
  overview-replication-controller,
  overview-pod,
  overview-deployment-config {
    .flex-display(@display: flex);
    width: 100%;
  }
  .service-group-header,
  .deployment-tile,
  .no-deployments-block .service-title {
    background-color: #ffffff;
    border: 1px solid @overview-border-gray;
    border-left-width: 0;
  }
  .service-group-header,
  .deployment-tile,
  .standalone-service .builds-block,
  .no-deployments-block .service-title,
  .service-group-triggers {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  }
  .standalone-service {
    width: 100%;
    display: flex;
    position: relative;
    overview-service {
      .flex(@columns: 0 0 100%);
    }
    .builds-block .builds .build:last-child {
      margin-bottom: @service-group-vertical-margin;
    }
    .service-group-body .overview-services {
      overview-service {
        max-width: none;
      }
      .deployment-tile {
        margin-top: 0;
      }
    }
    overview-service-group {
      width: 100%;
    }
    .service-group > div {
      .flex-display(@display: flex);
      .flex-direction(@direction: column);
      height: 100%;
    }
    .service-group-body {
      margin-top: 0;
      .overview-services .primary-service {
        .deployment-block {
          .flex-display(@display: flex);
        }
      }
    }
    .alert-wrapper .alert {
      margin-bottom: @service-group-vertical-margin;
      margin-top: 0;
    }
    .service-group-body {
      .flex-display(@display: flex);
      .flex-direction(@direction: column);
      width: 100%;
      .overview-services {
        .flex-direction(@direction: row);
        @media (min-width: @screen-sm-min) {
          min-height: 345px;
        }
        @media (min-width: @screen-md-min) {
          min-height: 255px;
        }
        overview-service,.no-child-services-message {
          max-width: none;
          margin-top: 0;
        }
        .no-child-services-message {
          display: none;
        }
      }
    }
  }
  .unserviced-row {
    .justify-content(@justify: space-between);
    .no-service {
      .flex-display(@display: flex);
      width: 100%;
      margin-bottom: 20px;
      position: relative;
      &:before {
        content: "";
        display: block;
        height: 100%;
        width: 3px;
        position: absolute;
        background: @color-pf-light-blue-400;
        left: 0;
        top: 0;
        z-index: 1;
      }
      @media (min-width: @two-column-min-width) {
        width: 50%;
        &:nth-child(odd) {
          padding-right: 3px;
        }
        &:nth-child(even) {
          padding-left: 3px;
          &:before {
            left: 3px;
          }
        }
      }
      .deployment-tile-wrapper {
        width: 100%;
      }
    }
  }
  .service-group-header {
    cursor: pointer;
    .flex-display(@display: flex);
    .justify-content(@justify: space-between);
    padding: 10px;
    .route-title {
      line-height: 1.4;
      // Margin at mobile if there is an app name. The route is stacked below the app name.
      margin: 0 0 0 6px;
      &:only-child {
        // Margin without app name.
        margin: 0;
      }
      @media (min-width: @screen-sm-min) {
        // At wider screen widths, always 0 margin.
        margin: 0;
      }
    }
    .app-name {
      .h3();
      .truncate();
      font-weight: 300;
      margin: 0;
      text-transform: uppercase;
      min-width: 130px; // prevent name from complete truncation at mobile
    }
    .other-routes-msg {
      display: block;
      line-height: 1.1;
      margin: 3px 20px;
    }
    @media (min-width: @screen-sm-min) {
      align-items: center;
      .other-routes-msg {
        display: inline-block;
        margin: 0;
      }
      &.has-app-label .other-routes-msg {
        // Display the message below the route when there is an app label.
        display: block;
        .text-right();
      }
    }
  }
  .service-group-body {
    border-top-width: 0;
    margin-top: @service-group-vertical-margin;
    padding: 0;
    .overview-services {
      .justify-content(@justify: space-between);
      .flex-display(@display: flex);
      .flex-wrap(@wrap: wrap);
      .flex-direction(@direction: column);
      overview-service {
        &:nth-child(n+3) {
          margin-top: @service-group-vertical-margin;
        }
        @media (max-width: 567px) {
          &:nth-child(n+2) {
            margin-top: @service-group-vertical-margin;
          }
        }
      }
      .deployment-block {
        .flex-display(@display: flex);
        .flex(@columns: 1 0 0%);
        &.service-multiple-targets, &.service-multiple-targets .deployment-tile-wrapper {
          display: block;
        }
      }
      .deployment-tile-wrapper {
        .flex-display(@display: flex);
        .flex(@columns: 1 0 0%);
        + .deployment-tile-wrapper {
          margin-top: @service-group-vertical-margin;
        }
      }
      .deployment-tile {
        .flex(@columns: 1 0 0%);
        position: relative;
      }
    }
  }
  // Set 2 column widths and padding
  @media (min-width: @two-column-min-width) {
    .service-group-with-route-row .overview-services {
      .flex-direction(@direction: row);
      overview-service {
        width: 50%;
        
        &:nth-child(even) {
          padding-left: 3px;
        }
        &:nth-child(odd) {
          padding-right: 3px;
        }
      }
    }
    @media (min-width: @two-column-min-width) { 
      .standalone-service-row .standalone-service {
        width: 50%;
        &:nth-child(odd) {
          padding-right: 3px;
        }
        &:nth-child(even) {
          padding-left: 3px;
        }
      }
    }
  }
  .component-label {
    .text-muted();
    font-size: @component-label;
    padding: 0 10px 4px 0;
    text-transform: uppercase;
  }
  .build-pipeline {
    // Avoid double borders inside the panel.
    margin-top: -1px;
  }
  .service-title {
    .text-muted();
    .align-items(@align: center);
    border-bottom: 1px solid @overview-border-gray;
    .justify-content(@justify: space-between);
    padding: 5px 10px;
  }
  .deployment-tile {
    border-left: 1px solid @overview-border-gray;
    width: 100%;
    .deployment-header {
      .text-muted();
      position: relative;
    }
    .rc-header {
      .text-muted();
      padding: 5px 10px;
    }
    .deployment-body {
      .flex-direction(@direction: column);
      padding: 10px;
      position: relative;
      .deployment-donut {
        .align-items(@align: center);
      }
      @media (min-width: @screen-md-min) {
        .flex-direction(@direction: row);
        // .justify-content(@justify: space-between);
        .justify-content(@justify: flex-end);
      }
    }
    .overview-donut, .overview-metrics {
      .align-items(@align: center);
    }
    .overview-metrics {
      @media (max-width: @screen-sm-max) {
        margin: 0 auto;
        .text-center();
      }
    }
    .overview-donut-connector {
      text-align: center;
      .deployment-connector-arrow {
        display: none;
      }
    }
    .overview-unsuccessful-state {
      text-align: center;
    }

    // fadeSlideOut
    @keyframes fadeSlideOut {
      0% { opacity: 1; }
      50% { opacity: 0; }
      100% { opacity: 0;
        margin-left: -300px; }
    }

    @keyframes flexGrow {
      to {
        .flex-basis(@width: 0%);
        .flex-grow(@grow: 1);
        .flex-shrink(@shrink: 1);
      }
    }

    @media (min-width: @screen-md-min) {
      .deployment-details {
        .align-items(@align: flex-start);
        .flex(@columns: 1 1 0%);
        padding-left: 30px;
        max-width: 50%;
        .flex-order(@order: 1);
        &.ng-leave {
          animation: fadeSlideOut .75s ease forwards; // Needs to be faster than flexGrow
        }
      }
      .overview-donut {
        .flex(@columns: 1 1 0%);
        .flex-order(@order: 2);
        max-width: 50%;
        min-height: 150px;
        &.latest {
          .flex-order(@order: 4);
          :last-child.latest.ng-animate {
            /* 0 does not work so we have to use a small number */
            .flex-basis(@width: 1);
            .flex-grow(@grow: 0.00001);
            .flex-shrink(@shrink: 1);
            animation: flexGrow 1s ease forwards;
          }
        }
      }
      .overview-donut-connector {
        .flex-order(@order: 3);
        font-size: 300%;
        color: #ccc;
        .align-items(@align: center);
        .justify-content(@justify: center);
        line-height: 1;
        .deployment-connector-arrow {
          display: block;
        }
      }
      .overview-unsuccessful-state {
        .flex(@columns: 1 1 0%);
        .flex-order(@order: 3);
        .align-items(@align: center);
        .justify-content(@justify: center);
        line-height: 1;
      }
      .deployment-status-msg {
        .text-muted();
        font-size: 16px;
        line-height: normal;
        margin-bottom: 10px;
        .deployment-log-link {
          font-size: 14px;
        }
      }
    }
    .deployment-tile {
      @media (min-width: @screen-sm-min) {
        max-width: 50%;
      }
    }
  }
  .no-deployments-block {
    .flex-display(@display: flex);
    height: 100%;
    width: 100%;
  }
  .no-child-services-block {
    padding-left: 3px;
    width: 50%;
  }
  .no-child-services-message, .no-deployments-message {
    .text-center();
    .text-muted();
    .well();
    .justify-content(@justify: center);
    margin-bottom: 0;
    padding: 0; // negate .well default padding to maintain equal widths
    h2 {
      &:first-child {
        margin-top: 15px;
      }
      @media (min-width: @two-column-min-width) {
        margin-top: 0;
      }
    }
  }
  .no-deployments-message {
    .flex(@columns: 1 0 0%); // the parent overview-service is where width with flex-basis is set.
  }
  .no-child-services-message {
    display: none;
    @media (min-width: @two-column-min-width) {
      .flex-display(@display: flex);
      .flex(@columns: 1 0 0%);
      .flex-direction(@direction: column);
    }
  }
  @media (min-width: @screen-md-min) {
    .overview-services.single-alternate-service {
      .primary-service .deployment-tile {
        border-right: 0;
        .service-title {
          padding-right: 0;
        }
      }
      // Remove the gap between the tiles.
      overview-service:nth-child(odd) {
        padding-right: 0;
      }
      overview-service:nth-child(even) {
        padding-left: 0;
      }
      .alternate-service {
        .deployment-tile {
          // Prevent the left box-shadow from appearing over the primary service tile.
          box-shadow: 2px 3px 6px -1px rgba(0, 0, 0, 0.1);
          .service-title {
            padding-left: 0;
          }
        }
        .service-metadata {
          order: -1;
          .traffic-label {
            display: none;
          }
          .progress {
            margin-left: 0;
            .progress-bar {
              background-color: @color-pf-blue-500;
            }
          }
        }
      }
    }
  }
  .deployment-tile {
    .traffic-label {
      display: inline-block;
    }
    .progress {
      background-color: inherit;
      border: 0;
      box-shadow: none;
      display: inline-block;
      margin: 0 0 0 5px;
      // Make sure the bar is wide enough to show the label for small percentages like 2%.
      min-width: 2em;
      vertical-align: -3px;
      .progress-bar {
        width: 100%;
      }
      @media (min-width: @screen-lg-min) {
        width: 250px;
      }
    }
  }
  .standalone-service-row {
    .justify-content(@justify: space-between);
  }
  .standalone-service .no-deployments-block {
    margin-left: 0;
    .no-deployments-message {
      margin-top: 0;
    }
  }
  .shield {
    background: @shield-bgcolor;
    border: 1px solid @shield-border-color;
    border-bottom: 0;
    width: @shield-width;
    position: absolute;
    .align-items(@align: center);
    right: 10px;
    top: -1px;
    z-index: 9;
    .shield-number {
      .flex-display(@display: flex);
      font-size: 11px;
      font-weight: 500;
      height: 30px;
      position: relative;
      width: @shield-width;
      .align-items(@align: center);
      .justify-content(@justify: center);
    }
    .shield-number:before {
      border-left: (@shield-width / 2) solid transparent;
      border-right: (@shield-width / 2) solid transparent;
      border-top: 10px solid @shield-border-color;
      content: "";
      height: 0;
      left: 0;
      position: absolute;
      bottom: -10px;
      width: 0;
    }
    .shield-number:after {
      border-left: (@shield-width / 2) solid transparent;
      border-right: (@shield-width / 2) solid transparent;
      border-top: 10px solid @shield-bgcolor;
      content: "";
      height: 0;
      left: 0;
      position: absolute;
      bottom: -9px;
      width: 0;
    }
    // Use if deployments > 999
    &.shield-lg {
      width: @shield-width-lg;
      .shield-number {width: @shield-width-lg;}
      .shield-number:before, .shield-number:after {
        border-left: (@shield-width-lg / 2) solid transparent;
        border-right: (@shield-width-lg / 2) solid transparent;
      }
    }
  }
}
